﻿// -------------------------------------------------------------------------
//    @FileName         :    NFCityWorldObject.h
//    @Author           :    Gao.Yi
//    @Date             :    2025-09-17
//    @Email			:    445267987@qq.com
//    @Module           :    NFCityWorldObject
//    @Desc             :
//
// -------------------------------------------------------------------------

#pragma once

#include "proto_common_base.nanopb.h"
#include "NFComm/NFObjCommon/NFNodeList.h"
#include "NFComm/NFObjCommon/NFObject.h"
#include "NFLogicCommon/NFLogicShmTypeDefines.h"

enum ECityWorldObjectType
{
    EN_CITY_WOT_NONE = 0,
    EN_CITY_WOT_PLAYER = 1,
    EN_CITY_WOT_NPC = 2,
};

class NFCityWorldObject : public NF_OBJECT_TEMPLATE_MACRO(NFCityWorldObject, EOT_CITY_WORLD_OBJECT_ID, NFObject, public NFListNodeObjWithGlobalId<NFCityWorldObject>)
public:
    NFCityWorldObject();
    ~NFCityWorldObject() override;
    int CreateInit();
    int ResumeInit();

public:
    virtual int OnEnterMap(int iMapInstId, int iMapDescId);
    virtual int OnLeaveMap();
    virtual int OnEnterGrid(int iMapGridIdx, int iMapGridId, const Proto_Vector3& oPos, int iDirection);
    virtual int OnLeaveGrid();
    virtual int MovePos(const Proto_Vector3& oPos, int iDirection);
protected:
    virtual int UpdateMapData(int iMapDescId, const Proto_Vector3& oPos, int iDirection) { return 0; }
    virtual int SynMapData() { return 0; }
public:
    bool IsEnterMap() { return m_iMapInstId >= 0; }
    virtual bool IsVisible(NFCityWorldObject* pAcceptWo) { return true; }
public:
    int GetMapInstId() const { return m_iMapInstId; }
    int GetMapDescId() const { return m_iMapDescID; }
    int GetMapGridIdx() const { return m_iMapGridIdx; }
    int GetMapGridId() const { return m_iMapGridId; }

    Proto_Vector3* GetPosition() { return &m_position; }
    int GetDirection() const { return m_iDirection; }

    void SetObjectType(ECityWorldObjectType cObjectType) { m_cObjectType = cObjectType; }
    char GetObjectType() const { return m_cObjectType; }

    bool IsPlayer() const { return m_cObjectType == EN_CITY_WOT_PLAYER; }
    bool IsNpc() const { return m_cObjectType == EN_CITY_WOT_NPC; }

private:
    int m_iMapInstId; // map object id ( not global-id)
    int m_iMapGridIdx; // grid index in map
    int m_iMapGridId; //map grid id

    int m_iMapDescID;

    Proto_Vector3 m_position;
    int m_iDirection;

    ECityWorldObjectType m_cObjectType;
};
